home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / OpenDoc 1.2b2c1 / Implementation / UI / StdWModM.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-13  |  21.1 KB  |  661 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        StdWModM.cpp
  3.  
  4.     Contains:    Implementation of DefaultWindowModule
  5.  
  6.     Owned by:    Chris Linn
  7.  
  8.     Copyright:    © 1994 - 1996 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <1>      11/27/96    CSL        first checked in
  13.  
  14.     To Do:
  15. */
  16.  
  17. /* 
  18.  
  19. Some Theory of Operation
  20.  
  21. In pure OpenDoc, i.e., no container application, this is the module that manages windows.
  22. It can assume that all windows are registered with OpenDoc except for dialog windows.  Any
  23. window that is not an ODWindow is treated as a dialog window for purposes of layering,
  24. acivation, etc..  The only exception to this is windows that are not visible on screen
  25. (ie, windows positioned far offscreen).  Off-screen windows are treated just like hidden
  26. windows--they are ignored entirely by this module.
  27.  
  28. A container application that creates its own windows (that are not registered with OpenDoc)
  29. will need to write its own window handler module that makes windows behave properly.  A
  30. custom window handler module will know about the application's windows, and it will be
  31. able to ask OpenDoc about part windows (i.e. floating or not), but it will need to assume
  32. that any window that was not created by the application and is not an ODWindow is therefore
  33. a dialog window created by a part.
  34.  
  35. About window behavior in this module:
  36.  
  37. Windows that are hidden are ignored, since the toolbox likes to move hidden windows around 
  38. in the window list.  When a window is shown, it is repositioned in the window list only if 
  39. it is currently in the wrong layer (e.g. you don't want a floater to appear behind a 
  40. document window).
  41.  
  42. Dialogs appear above floaters, floaters appear above document (regular OpenDoc) windows.
  43. All floating windows are active when there is no visible dialog window.  The top-most 
  44. document window is active when there is no visible dialog window.  Only the top-most dialog 
  45. window is active when one or more dialog windows are visible.
  46.  
  47. Note that parts may choose to implement a dialog window as an ODWindow.  In this case,
  48. OpenDoc does not know that the window is a dialog, and treats it like a document window.
  49. It turns out that there are only two problems with doing this.  First, such a window
  50. is presented behind floating windows.  In practice, this isn't an issue because the
  51. root frame in the dialog window gets the selection focus, causing floating windows owned
  52. by other frames to be hidden.  In a container application, however, it may still cause
  53. the dialog to appear behind the container's floating windows, if they are visible.
  54.  
  55. The second problem is with nested dialogs.  If the first dialog presented is not an
  56. ODWindow (such as part info), but a nested dialog is an ODWindow, the nested dialog will
  57. always appear behind the first dialog window.  There is no workaround for this limitation
  58. at this time.  Nested dialogs cannot be ODWindows.
  59.  
  60. */
  61.  
  62. /*
  63.  *  This file was generated by the SOM Compiler.
  64.  *  Generated using:
  65.  *     SOM incremental update: 2.33
  66.  */
  67.  
  68.  
  69. #ifndef _STDWMODM_
  70. #include "StdWModM.h"
  71. #endif
  72.  
  73. #ifndef __WINDOWS__
  74. #include <Windows.h>
  75. #endif
  76.  
  77. #ifndef SOM_ODWindowState_xh
  78. #include "WinStat.xh"
  79. #endif
  80.  
  81. #ifndef SOM_ODWindow_xh
  82. #include "Window.xh"
  83. #endif
  84.  
  85. #ifndef SOM_ODWinIter_xh
  86. #include "WinIter.xh"
  87. #endif
  88.  
  89. #ifndef _WINUTILM_
  90. #include "WinUtilM.h"
  91. #endif
  92.  
  93. #ifndef _TEMPOBJ_
  94. #include "TempObj.h"
  95. #endif
  96.  
  97.  
  98. //-------------------------------------------------------------------------------------
  99. #pragma mark --- Private Classes ---
  100. //-------------------------------------------------------------------------------------
  101.  
  102. //-------------------------------------------------------------------------------------
  103. #pragma mark WindowInfo
  104. //-------------------------------------------------------------------------------------
  105.  
  106. class WindowInfo
  107. {
  108. public:
  109.     WindowInfo() : window( kODNULL ), odWindow( kODNULL ), layer( 0 ) {};
  110.  
  111.     ODPlatformWindow    window;
  112.     TempODWindow        odWindow;
  113.     ODWindowLayer        layer;
  114. };
  115.  
  116.  
  117. //-------------------------------------------------------------------------------------
  118. #pragma mark --- Static Utilities ---
  119. //-------------------------------------------------------------------------------------
  120.  
  121. //-------------------------------------------------------------------------------------
  122. // IsWindowBehind
  123. //-------------------------------------------------------------------------------------
  124.  
  125. static ODBoolean IsWindowBehind(
  126.         WindowPtr testWindow,
  127.         WindowPtr referenceWindow )
  128. {
  129.     ODBoolean isWindowBehind = kODFalse;
  130.     
  131.     WindowPtr window = ::GetWindowList();
  132.     while ( window != kODNULL )
  133.     {
  134.         if ( window == testWindow )
  135.             break;
  136.         
  137.         if ( window == referenceWindow )
  138.         {
  139.             isWindowBehind = kODTrue;
  140.             break;
  141.         }
  142.     
  143.         window = ::GetNextWindow( window );
  144.     }
  145.     
  146.     return isWindowBehind;
  147. }
  148.  
  149.  
  150. //-------------------------------------------------------------------------------------
  151. // IsWindowVisibleOnDesktop
  152. //
  153. // Returns true if the window's visible flag is set AND the window actually
  154. // intersects the desktop region.  This allows us to ignore windows that
  155. // are hidden way offscreen, often in Small Negative Numbers Land.  Cyberdog
  156. // has a few of these, natch.
  157. //-------------------------------------------------------------------------------------
  158.  
  159. static ODBoolean IsWindowVisibleOnDesktop( WindowPtr window )
  160. {
  161.     return ::IsWindowVisible( window )
  162.            && ::RectInRgn( &(**((WindowPeek)window)->strucRgn).rgnBBox, GetGrayRgn());
  163. }
  164.  
  165.  
  166. //-------------------------------------------------------------------------------------
  167. // GetNextVisibleWindow
  168. //-------------------------------------------------------------------------------------
  169.  
  170. static WindowPtr GetNextVisibleWindow( WindowPtr startingWindow )
  171. {
  172.     WindowPtr nextVisibleWindow = 
  173.                 ( startingWindow == kODNULL ? ::FrontWindow()
  174.                                               : ::GetNextWindow( startingWindow ));
  175.  
  176.     while ( !( nextVisibleWindow == kODNULL 
  177.                || ::IsWindowVisibleOnDesktop( nextVisibleWindow )))
  178.     {
  179.         nextVisibleWindow = ::GetNextWindow( nextVisibleWindow );
  180.     }
  181.  
  182.     return nextVisibleWindow;
  183. }
  184.  
  185.  
  186. //-------------------------------------------------------------------------------------
  187. // GetWindowLayer
  188. //-------------------------------------------------------------------------------------
  189.  
  190. static ODWindowLayer GetWindowLayer( Environment* ev, ODWindow* odWindow )
  191. {
  192.     return ( odWindow == kODNULL )
  193.              ? kODWinLayerDialog : (( odWindow->IsFloating( ev ))
  194.                                      ? kODWinLayerFloating
  195.                                      : kODWinLayerDocument );
  196. }
  197.  
  198.  
  199. //-------------------------------------------------------------------------------------
  200. // IsLayerAbove
  201. //-------------------------------------------------------------------------------------
  202.  
  203. static inline ODBoolean IsLayerAbove( ODWindowLayer testLayer, ODWindowLayer referenceLayer )
  204. {
  205.     // Layers are numbered sequentially, so this test is easy.
  206.     return testLayer < referenceLayer;
  207. }
  208.  
  209.  
  210. //-------------------------------------------------------------------------------------
  211. // IsFrontProcess
  212. //-------------------------------------------------------------------------------------
  213.  
  214. static ODBoolean IsFrontProcess()
  215. {
  216.     ProcessSerialNumber    currentPSN;
  217.     ProcessSerialNumber    frontPSN;
  218.     OSErr                getFrontProcessResult;
  219.     OSErr                getCurrentProcessResult;
  220.     ODBoolean            isSameProcess = kODFalse;
  221.     
  222.     // Compare this process and the front process
  223.     getFrontProcessResult = ::GetFrontProcess( &frontPSN );
  224.     getCurrentProcessResult = ::GetCurrentProcess( ¤tPSN );
  225.     
  226.     if (    ( getFrontProcessResult   == noErr ) 
  227.          && ( getCurrentProcessResult == noErr ))
  228.         ::SameProcess( &frontPSN, ¤tPSN, &isSameProcess );
  229.         
  230.     return isSameProcess;
  231. }
  232.  
  233.  
  234. //-------------------------------------------------------------------------------------
  235. // SetWindowActive
  236. //-------------------------------------------------------------------------------------
  237.  
  238. static void SetWindowActive( WindowPtr window, ODBoolean activeState )
  239. {
  240.     ::SetWindowHilite( window, ::IsFrontProcess() ? activeState : kODFalse );
  241. }
  242.  
  243.  
  244. //-------------------------------------------------------------------------------------
  245. #pragma mark --- Private Methods ---
  246. //-------------------------------------------------------------------------------------
  247.  
  248.  
  249. //-------------------------------------------------------------------------------------
  250. // DefaultWindowModule::GetFirstVisibleNonFloatingWindow
  251. //-------------------------------------------------------------------------------------
  252.  
  253. ODPlatformWindow DefaultWindowModule::GetFirstVisibleNonFloatingWindow( Environment *ev)
  254. {
  255.     // Return the top-most visible window in the window list that is not a floater.
  256.     // The returned window may be either a dialog or a document window.  A window that
  257.     // is not an ODWindow is assumed to be a dialog.  The window returned is the
  258.     // active non-floating window, or kODNULL if there are no visible non-floaters.
  259.  
  260.     WindowPtr            firstNonFloatingWindow = kODNULL;
  261.     ODWindowIterator*    iter = kODNULL;                        ODVolatile( iter );
  262.  
  263.     TRY
  264.  
  265.         ODWindow*    odWindow = kODNULL;
  266.         WindowPtr    window = ::FrontWindow();
  267.  
  268.         iter = fWindowState->CreateWindowIterator( ev );
  269.  
  270.         while ( window != kODNULL && firstNonFloatingWindow == kODNULL ) 
  271.         {
  272.             for ( odWindow = iter->First( ev ); 
  273.                   iter->IsNotComplete( ev );
  274.                   odWindow = iter->Next( ev ))
  275.             {
  276.                 if ( odWindow->GetPlatformWindow(ev) == window )
  277.                 {
  278.                     if ( !odWindow->IsFloating( ev ))
  279.                     {
  280.                         firstNonFloatingWindow = window;
  281.                     }
  282.                     break;
  283.                 }
  284.             }
  285.             if ( odWindow == kODNULL )    // i.e., this one is not an ODWindow
  286.                 firstNonFloatingWindow = window;
  287.  
  288.             window = ::GetNextVisibleWindow( window );
  289.         }
  290.         ODDeleteObject( iter );
  291.  
  292.     CATCH_ALL
  293.  
  294.         firstNonFloatingWindow = kODNULL;
  295.         ODDeleteObject( iter );
  296.         RERAISE;
  297.  
  298.     ENDTRY
  299.  
  300.     return firstNonFloatingWindow;
  301. }
  302.  
  303.  
  304. //-------------------------------------------------------------------------------------
  305. // DefaultWindowModule::BringToFrontOfLayer
  306. //-------------------------------------------------------------------------------------
  307.  
  308. void DefaultWindowModule::MoveWindowToLayer( Environment *ev,
  309.         WindowInfo& input,
  310.         ODBoolean toFront )
  311. {
  312.     // Do two things: move a window into its layer if it is in another layer,
  313.     // and move the window to the front of its layer if the toFront parameter
  314.     // is true.  For step one, if the window is behind its layer, the window
  315.     // is moved to be behind the last window in its layer.  If the window is
  316.     // in a layer above where it should be, the window is simply moved to the
  317.     // front of it's layer.  The logic gets sort of tricky because you need
  318.     // to deal with all the edge cases where there are no windows visible in
  319.     // one or more of the layers involved.
  320.  
  321.     WindowPtr            lastAboveLayer = kODNULL;
  322.     WindowPtr            lastBeforeNextLayer = kODNULL;
  323.     ODWindowIterator*    iter = kODNULL;                        ODVolatile( iter );
  324.  
  325.     TRY
  326.     
  327.         // Find the last visible window above the input window's layer
  328.         // and the last visible window before the layer below the input window
  329.         // (ie, if there are currently no visible windows in the input layer,
  330.         // the last window before the next layer might be in the layer ABOVE
  331.         // the input layer).
  332.         ODWindow*    searchODWindow = kODNULL;
  333.         WindowPtr    searchWindow = ::FrontWindow();
  334.         iter = fWindowState->CreateWindowIterator( ev );
  335.  
  336.         while ( searchWindow != kODNULL ) 
  337.         {
  338.             searchODWindow = iter->First( ev );
  339.             while ( iter->IsNotComplete( ev ) 
  340.                       && searchODWindow->GetPlatformWindow(ev) != searchWindow )
  341.             {
  342.                 searchODWindow = iter->Next( ev );
  343.             }
  344.  
  345.             // GetWindowLayer works even if searchODWindow is NULL
  346.             // (the window is put in the dialog layer if no ODWindow can be found).
  347.             ODWindowLayer searchLayer = ::GetWindowLayer( ev, searchODWindow );
  348.             if ( ::IsLayerAbove( searchLayer,
  349.                                  input.layer ))
  350.             {
  351.                 lastAboveLayer = searchWindow;
  352.                 lastBeforeNextLayer = searchWindow;
  353.             }
  354.             else if ( searchLayer == input.layer )
  355.                 lastBeforeNextLayer = searchWindow;
  356.             else
  357.                 break;    // Optimization: stop searching after input's layer
  358.             
  359.             searchWindow = ::GetNextVisibleWindow( searchWindow );
  360.         }
  361.         ODDeleteObject( iter );
  362.  
  363.         // Move the window as needed.
  364.         // This is the only code in the entire class that changes the z-ordering
  365.         // of windows.
  366.         if ( lastAboveLayer == kODNULL
  367.              && ( toFront || lastBeforeNextLayer == kODNULL ))
  368.         {
  369.             // The window should appear in front of all others.
  370.             ::BringToFront( input.window );
  371.         }
  372.         else if ( lastAboveLayer != kODNULL
  373.                   && ( toFront || !::IsWindowBehind( input.window, lastAboveLayer )))
  374.         {
  375.             // The window should appear at the front of its layer.
  376.             ::SendBehind( input.window, lastAboveLayer );
  377.         }
  378.         else if ( lastBeforeNextLayer != kODNULL
  379.                   && ::IsWindowBehind( input.window, lastBeforeNextLayer ))
  380.         {
  381.             // The window has drifted back into a deeper layer
  382.             // (thanks to the toolbox) and needs to be brought
  383.             // forward to appear at the back of its layer.
  384.             ::SendBehind( input.window, lastBeforeNextLayer );
  385.         }
  386.  
  387.     CATCH_ALL
  388.     
  389.         ODDeleteObject( iter );
  390.         RERAISE;
  391.  
  392.     ENDTRY
  393. }
  394.  
  395.  
  396. //-------------------------------------------------------------------------------------
  397. // DefaultWindowModule::SetFrontWindowsActiveState
  398. //-------------------------------------------------------------------------------------
  399.  
  400. void DefaultWindowModule::SetFrontWindowsActiveState( Environment *ev,
  401.         ODBoolean activeState)
  402. {
  403.     WindowPtr firstNonFloater = this->GetFirstVisibleNonFloatingWindow( ev );
  404.     WindowPtr window = ::FrontWindow();
  405.  
  406.     // Starting at the top, set the active state of all visible windows
  407.     // down to the first non floating window
  408.  
  409.     while ( window != kODNULL )
  410.     {
  411.         TempODWindow odWindow = 
  412.                 fWindowState->AcquireODWindow( ev, window );
  413.  
  414.         if ( odWindow == kODNULL )
  415.         {
  416.             // This window is not an ODWindow.
  417.             // Assume it is a dialog and set the hilite.
  418.             ::SetWindowActive( window, activeState );
  419.         }
  420.         else if ( activeState )
  421.             odWindow->Activate( ev );
  422.         else
  423.             odWindow->Deactivate( ev );
  424.         
  425.         // Time to stop?
  426.         if ( window == firstNonFloater )
  427.             break;
  428.  
  429.         window = ::GetNextVisibleWindow( window );
  430.     }
  431. }
  432.  
  433.  
  434. //-------------------------------------------------------------------------------------
  435. // DefaultWindowModule::Normalize
  436. //-------------------------------------------------------------------------------------
  437.  
  438. void DefaultWindowModule::Normalize( Environment *ev,
  439.         ODPlatformWindow inputWindow,
  440.         WindowInfo& inputInfo,
  441.         WindowInfo& activeInfo)
  442. {
  443.     // Fill in the inputInfo and activeInfo structures, based on the input the
  444.     // inputWindow and the active window, respectively.
  445.  
  446.     inputInfo.window = inputWindow;
  447.     if ( inputWindow != kODNULL )
  448.     {
  449.         inputInfo.odWindow = fWindowState->AcquireODWindow( ev, inputWindow );
  450.         inputInfo.layer = ::GetWindowLayer( ev, inputInfo.odWindow );
  451.     }
  452.  
  453.     // It's important that we determine which window is "active" based solely
  454.     // on position in the window list as opposed to the hilite state or the
  455.     // value returned by ODWindow::IsActive().  The position technique is
  456.     // independent of whether the process is in the foreground or background,
  457.     // which is what we need.  Thus, in this context, the "active" window means
  458.     // the window which is active when the process is in the foreground.
  459.     activeInfo.window = this->GetFirstVisibleNonFloatingWindow( ev );
  460.     if ( activeInfo.window != kODNULL )
  461.     {
  462.         activeInfo.odWindow = fWindowState->AcquireODWindow( ev, activeInfo.window );
  463.         activeInfo.layer = ::GetWindowLayer( ev, activeInfo.odWindow );
  464.     }
  465. }
  466.  
  467.  
  468. //-------------------------------------------------------------------------------------
  469. #pragma mark --- Public Methods ---
  470. //-------------------------------------------------------------------------------------
  471.  
  472. //-------------------------------------------------------------------------------------
  473. // DefaultWindowModule::InitDefaultWindowModule
  474. //-------------------------------------------------------------------------------------
  475.  
  476. void DefaultWindowModule::InitDefaultWindowModule( Environment *ev,
  477.         ODWindowState* windowState)
  478. {
  479.     if ( windowState == kODNULL )
  480.         THROW( kODErrIllegalNullInput );
  481.  
  482.     fWindowState = windowState;
  483. }
  484.  
  485.  
  486. //-------------------------------------------------------------------------------------
  487. // DefaultWindowModule::ShowWindow
  488. //-------------------------------------------------------------------------------------
  489.  
  490. void DefaultWindowModule::ShowWindow( Environment *ev,
  491.         ODPlatformWindow window,
  492.         ODWindowLayer layer)
  493. {
  494.     // The window being shown is not assumed to be hidden beforehand.  This is
  495.     // because this method is used when an already visible window is added 
  496.     // (ie, registered with OpenDoc) to force the window into the right layer.
  497.     
  498.     // Note that we don't keep a list of windows and layers.
  499.     // Instead, we rely on ODWindowState to keep track window layers.  This
  500.     // is a simple technique that works only because this module is running
  501.     // in "pure" OpenDoc, with no container app windows.  In a container app,
  502.     // this module would need to add this window and it's layer to an internal
  503.     // list of all the windows in the process, and then use that list during
  504.     // other method calls.
  505.  
  506.     WindowInfo input;
  507.     WindowInfo active;
  508.     this->Normalize( ev, window, input, active );
  509.  
  510.     // Figure out if the window needs to be active.
  511.     // This is a little tricky.  Floaters are active if no
  512.     // dialogs are active.  Others in front (document & dialog windows)
  513.     // need to be Selected so that the currently active window
  514.     // gets deactivated.
  515.     if ( input.layer == kODWinLayerFloating )
  516.     {
  517.         // Make sure the window will appear in the right layer.
  518.         this->MoveWindowToLayer( ev, input, kODFalse /* !BringToFront */ );
  519.         if ( active.window == kODNULL
  520.              || active.layer == kODWinLayerDocument )
  521.         {
  522.             input.odWindow->Activate( ev );
  523.         }
  524.     }
  525.     else if ( input.layer == kODWinLayerDialog
  526.               || active.window == kODNULL
  527.               || !::IsWindowBehind( input.window, active.window ))
  528.     {
  529.         // Select windows that should be active (front non-floaters)
  530.         if ( input.odWindow != kODNULL )
  531.             input.odWindow->Select( ev );
  532.         else
  533.             this->SelectWindow( ev, input.window );
  534.     }
  535.     else
  536.     {
  537.         // Make sure the window will appear in the right layer.
  538.         this->MoveWindowToLayer( ev, input, kODFalse /* !BringToFront */ );
  539.     }
  540.  
  541.     // Finally, show the window.
  542.     ::ShowHide( input.window, kODTrue );
  543. }
  544.  
  545.  
  546. //-------------------------------------------------------------------------------------
  547. // DefaultWindowModule::HideWindow
  548. //-------------------------------------------------------------------------------------
  549.  
  550. void DefaultWindowModule::HideWindow( Environment *ev,
  551.         ODPlatformWindow window)
  552. {
  553.     WindowInfo input;
  554.     WindowInfo active;
  555.     this->Normalize( ev, window, input, active );
  556.  
  557.     // Deactivate it in case it's active
  558.     // (It's safe and fast to call Deactivate() on an inactive window) 
  559.     if ( input.odWindow != kODNULL )
  560.         input.odWindow->Deactivate( ev );
  561.  
  562.     // Hide the window
  563.     ::ShowHide( input.window, kODFalse );
  564.  
  565.     if ( input.window == active.window )
  566.     {
  567.         // We just hid the active window, so now we need to activate the
  568.         // new set of front windows (ie, floaters too, if needed)
  569.         fWindowState->ActivateFrontWindows( ev );
  570.     }
  571. }
  572.  
  573.  
  574. //-------------------------------------------------------------------------------------
  575. // DefaultWindowModule::SelectWindow
  576. //-------------------------------------------------------------------------------------
  577.  
  578. void DefaultWindowModule::SelectWindow( Environment *ev,
  579.         ODPlatformWindow window)
  580. {
  581.     // The window being selected is not assumed to be visible.  This allows
  582.     // a window to be activated just before being shown.  See the Show() method.
  583.  
  584.     ODBoolean shouldActivate = kODFalse;
  585.     WindowInfo input;
  586.     WindowInfo active;
  587.     this->Normalize( ev, window, input, active );
  588.  
  589.     // If the window displaces the active window, deactivate the active window.
  590.     // Also figure out if the window should be active after bringing it to the
  591.     // front of its layer.
  592.     if ( input.window != active.window )
  593.     {
  594.         switch( input.layer )
  595.         {
  596.             case kODWinLayerDocument:
  597.                 // If no dialogs are visible, deactivate the front doc window
  598.                 if ( active.window == kODNULL
  599.                      || active.layer == kODWinLayerDocument )
  600.                 {
  601.                     shouldActivate = kODTrue;
  602.                     if ( active.odWindow != kODNULL )
  603.                         active.odWindow->Deactivate( ev );
  604.                     else if ( active.window != kODNULL )
  605.                         ::SetWindowActive( active.window, kODFalse );
  606.                 }
  607.                 break;
  608.  
  609.             case kODWinLayerFloating:
  610.                 // If no dialogs are visible, mark the window to be activated
  611.                 if ( active.window == kODNULL
  612.                      || active.layer == kODWinLayerDocument )
  613.                 {
  614.                     shouldActivate = kODTrue;
  615.                 }
  616.                 break;
  617.             
  618.             case kODWinLayerDialog:
  619.                 // Always activate a dialog.
  620.                 shouldActivate = kODTrue;
  621.                 fWindowState->DeactivateFrontWindows( ev );
  622.                 break;
  623.     
  624.             default:
  625.                 break;
  626.         }
  627.     }
  628.  
  629.     // Bring the window to the front of its layer.
  630.     this->MoveWindowToLayer( ev, input, kODTrue /* BringToFront */ );
  631.  
  632.     // Finally, if it should be active, activate it.
  633.     if ( shouldActivate )
  634.     {
  635.         if ( input.odWindow != kODNULL )
  636.             input.odWindow->Activate( ev );
  637.         else
  638.             ::SetWindowActive( input.window, kODTrue );
  639.     }
  640. }
  641.  
  642.  
  643. //-------------------------------------------------------------------------------------
  644. // DefaultWindowModule::DeactivateFrontWindows
  645. //-------------------------------------------------------------------------------------
  646.  
  647. void DefaultWindowModule::DeactivateFrontWindows( Environment *ev)
  648. {
  649.     this->SetFrontWindowsActiveState( ev, kODFalse );
  650. }
  651.  
  652.  
  653. //-------------------------------------------------------------------------------------
  654. // DefaultWindowModule::ActivateFrontWindows
  655. //-------------------------------------------------------------------------------------
  656.  
  657. void DefaultWindowModule::ActivateFrontWindows( Environment *ev)
  658. {
  659.     this->SetFrontWindowsActiveState( ev, kODTrue );
  660. }
  661.